Disposing of a Job Object When Closing a Document
When the user chooses the Close menu command from the File menu to close a document, you need to dispose of its job object. You should not dispose of a job object while its document is open.For each page in a document, you should dispose of the page's shape. You can then call the
GXDisposeJob
function to dispose of a document's job object and associated format objects. Listing 2-9 shows how to dispose of a job object when a user closes a document.Listing 2-9 Disposing of a job object when you close a document
OSErr MyCloseDocument(MyDocumentPtr myDocument) { OSErr err = noErr, jobErr; long pg; /* Dispose of each page's shape */ for (pg = 1; pg <= myDocument->numPages; pg++) GXDisposeShape(myDocument->documentPage[pg-1]); /* Dispose of the document's corresponding job object. */ err = GXDisposeJob(myDocument->documentJob); /* Place any application-specific code here to close a document. */ ... DisposeWindow(myDocument->documentWindow); return err; }
- Note
- The
GXDisposeJob
function returns an error because errors are job-oriented. You cannot query a job object for errors once you have disposed of it.![]()
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help